import request from '../../utils/request'

Page({
    data:{
        bannerList:[],
        recommendList:[],
        topList:[]
    },
    async onLoad(){
        // 轮播图
        request("/banner").then(res => {
            // console.log(res);
            this.setData({
                bannerList:res.data.banners
            })
        })
        // 推荐歌曲
        request("/personalized",{limit:6}).then(res => {
            // console.log(res);
            this.setData({
                recommendList:res.data.result
            })
        })
        // 排行榜
        let index = 0
        let resultArr = []
        while(index<5){
            let topListData = await request("/top/list",{idx:index++})
                let topListItem = {name:topListData.data.playlist.name,tracks:topListData.data.playlist.tracks.slice(0,3)}
                resultArr.push(topListItem)
        }
        console.log(resultArr);    
        this.setData({
            topList:resultArr
        })

    }
})